<template>
  <!--表单组件-->
  <el-dialog
    append-to-body
    width="500px"
    :close-on-click-modal="false"
    :before-close="crud.cancelCU"
    :visible.sync="crud.status.cu > 0"
    :title="crud.status.title"
  >
    <el-form
      ref="form"
      :model="form"
      :rules="rules"
      size="small"
      label-width="80px"
    >
      <el-form-item label="id" v-show="false">
        <el-input v-model="form.id" style="width: 370px" />
      </el-form-item>

      <el-form-item :label="inputName + '编码'" prop="modelCode">
        <el-input
          v-model="form.modelCode"
          style="width: 370px"
          :placeholder="'请输入' + inputName + '编码'"
        />
      </el-form-item>

      <el-form-item :label="inputName + '名称'" prop="modelName">
        <el-input
          v-model="form.modelName"
          style="width: 370px"
          :placeholder="'请输入' + inputName + '名称'"
        />
      </el-form-item>

      <el-form-item label="描述">
        <el-input
          v-model="form.remark"
          style="width: 370px"
          type="textarea"
          :rows="4"
          placeholder="不超过500个字符"
        ></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="text" @click="crud.cancelCU">取消</el-button>
      <el-button
        :loading="crud.status.cu === 2"
        type="primary"
        @click="crud.submitCU"
        >确认</el-button
      >
    </div>
  </el-dialog>
</template>

<script>
import { form } from "@crud/crud";

const defaultForm = {
  id: null,
  modelName: "",
  modelCode: "",
  remark: "",
  modelType: "0",
  pid: 0,
};
export default {
  mixins: [form(defaultForm)],
  props: {
    inputName: String
  },
  data() {
    return {
      rules: {
        modelName: [
          {
            required: true,
            message: "请输入" + this.inputName + "名称",
            trigger: "blur",
          },
        ],
        modelCode: [
          {
            required: true,
            message: "请输入" + this.inputName + "编码",
            trigger: "blur",
          },
        ],
      },
    };
  },
  methods: {
    getModelType: function () {
      switch (defaultForm.modelType) {
        case "0":
          return "工厂";
        case "1":
          return "车间";
        case "2":
          return "产线";
        case "3":
          return "工段";
        case "4":
          return "工站";
        default:
          return "";
      }
    },
  },
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
::v-deep .el-input-number .el-input__inner {
  text-align: left;
}
</style>
